/**
 *  @file HttpMessage.h
 */
#ifndef _HTTPMESSAGE_H_
#define _HTTPMESSAGE_H_

#include "../../common/BaseObject.h"
#include "HttpConst.h"
#include "../../text/CFString.h"
#include "../../collections/KeyValueListT.h"
#include "message/IHttpBody.h"

namespace cppflib
{

namespace net
{

namespace http
{

/**
 *  A base class for HttpRequest and HttpResponse
 */
class _DLLAPI HttpMessage : public BaseObject
{
private:
    CFString httpVersion;
    collections::NameValueList * pHeaders;
    message::IHttpBody * pBody;

protected:
    HttpMessage(void);

public:
    virtual ~HttpMessage(void);

    void SetHttpVersion(pcwstr_t ver);
    void SetHeader(pcwstr_t name, pcwstr_t val, bool isReplace = true);
    void SetHttpBody(message::IHttpBody *pHttpBody);

    const CFString& GetHttpVersion(void);
    u32_t GetHeaderCount(void);
    bool GetHeader(int index, CFString*& name, CFString*& value);
    bool GetHeaderValue(const CFString& name, CFString*& value);
    bool HeaderExists(const CFString& name);
    bool HeaderValueExists(const CFString& name, const CFString &value);
    bool HasHttpBody(void);
    message::IHttpBody * GetHttpBody(void);
    
    bool ExpectContinueExists();
    bool ChunkTransferEncodingExists();
    bool CompressedContentExists();
    bool IsVersion1Point1();

    PUBLIC bool CanRequestHaveBody(httpmethod_t method);
    PUBLIC bool CanResponseHaveBody(httpmethod_t method);
    PUBLIC bool ResponseCodeHaveNoBody(int statusCode);
};


} // end of namespace http

} // end of namespace net

} // end of namespace cppflib


#endif
